#!/usr/bin/env python
# Last Change: 2010-03-17 22:52:58

from util import *

@abstract
class item:
  pass
  
@abstract
class handler:

  @abstract
  def name(self):
    pass

  @abstract
  def accept(self, url):
    pass

  @abstract
  def list(self, url):
    pass

  @abstract
  def format(self, url, cols):
    pass

@singleton
class manager:

  def __init__(self):
    self.handlers = []
    self.plugins = []

  def reg(self, plugin):
    self.plugins.append(plugin)
    for h in plugin.handlers():
      self.handlers.append(h)
    
  def find(self, uri):
    for h in handlers:
      if h.accept(uri):
        return h
    return None

